package com.ezops.poc.validations.validators.converter;

import java.util.ArrayList;
import java.util.List;

public class EzopsFixedValueConverter implements ITypeConverter {

	@Override
	public void tryConvert(String value, String format)
			throws ConversionException, UnknownFormatException {
		List<String> allowedValues = new ArrayList<>();
		// format defines all fixed values
		for(String allowedValue :format.split(",")){
			allowedValues.add(allowedValue.trim().toLowerCase());
		}
		if (allowedValues.contains(value.toLowerCase()) == false) {
			throw new ConversionException("Fixed", value,
					"Value is not in predefined possible values");
		}

	}

}
